package com.xiaozhen.blog.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;


/**
 * @create 2023-05-07 13:49
 */
@Component
@Aspect
public class UvAspect {
    @Autowired
    private RedisTemplate redisTemplate;

    // 方法上有 @UvBlog 注解注释的方法就是切点
    @Pointcut("@annotation(com.xiaozhen.blog.aop.UvBlog)")
    private void blog(){}

    // 调用方法后都会进行统计操作，写入 redis
    public void afterMethod(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        String redisKey = "UvBlog" + args[0];
        redisTemplate.opsForValue();
    }
}
